home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Developer University / DU Projects / Data / Sources / Content.cpp < prev    next >
Encoding:
Text File  |  1996-08-22  |  3.1 KB  |  122 lines  |  [TEXT/CWIE]

  1. //    Release Version:    $ ODF 2 $
  2. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //========================================================================================
  5. #include "Data.hpp"
  6.  
  7. #ifndef CONTENT_H
  8. #include "Content.h"
  9. #endif
  10.  
  11. #ifndef PART_H
  12. #include "Part.h"
  13. #endif
  14.  
  15. #ifndef PIZZA_H
  16. #include "Pizza.h"            //  CPizza
  17. #endif
  18.  
  19. //--- OpenDoc ------------------------------------------------------------------
  20. #ifndef SOM_Module_OpenDoc_StdProps_defined
  21. #include <StdProps.xh>        // kODPropContents
  22. #endif
  23.  
  24. //========================================================================================
  25. #ifdef FW_BUILD_MAC
  26. #pragma segment Data
  27. #endif
  28.  
  29. //========================================================================================
  30. FW_DEFINE_AUTO(CPizzaCollection)
  31. FW_DEFINE_AUTO(CPizzaCollectionIterator)
  32. FW_DEFINE_AUTO(CDataContent)
  33.  
  34. //----------------------------------------------------------------------------------------
  35. CDataContent::CDataContent(Environment* ev, CDataPart* part)
  36.  :    FW_CContent(ev, part),
  37.     fStringPtr(NULL),
  38.     fBufferPtr(NULL),
  39.     fBufferBytes(0),
  40.     fPart(part),
  41.     fNumPizzas(0),
  42.     fPizzaList(NULL)
  43. {
  44.     fEmbeddedString.ReplaceAll("Embedded string");
  45.     fStringPtr = FW_NEW(FW_CString32, ("String Pointer") );
  46.  
  47.     // init buffer
  48.     fBufferBytes = 1000;
  49.     fBufferPtr = FW_CMemoryManager::AllocateBlock(fBufferBytes);    
  50.  
  51.     fPizzaList = FW_NEW(CPizzaCollection, ());
  52.     FW_END_CONSTRUCTOR
  53. }
  54.  
  55. //----------------------------------------------------------------------------------------
  56. CDataContent::~CDataContent()
  57. {
  58.     FW_START_DESTRUCTOR
  59.     delete fStringPtr;
  60.     FW_CMemoryManager::FreeBlock(fBufferPtr);
  61.     CPizza* pizza = NULL;
  62.     while ((pizza = fPizzaList->First()) != NULL) {
  63.         fPizzaList->Remove(pizza);
  64.         delete pizza;
  65.         }
  66.     delete fPizzaList;
  67. }
  68.  
  69. //----------------------------------------------------------------------------------------
  70. CPizzaCollection*
  71. CDataContent::MyGetPizzaList()
  72. {
  73.     return fPizzaList;
  74. }
  75.  
  76. //----------------------------------------------------------------------------------------
  77. void
  78. CDataContent::MyIncrement(Environment* ev, FW_CPoint& position)
  79. {
  80.     fNumPizzas++;
  81.  
  82.     FW_CPoint halfSize( FW_IntToFixed(15), FW_IntToFixed(15) );
  83.     FW_CRect bounds(position - halfSize, position + halfSize);
  84.  
  85.     CPizza* pizza = new CPizza(bounds);
  86.     fPizzaList->AddLast(pizza);
  87.     fPart->MyInvalidatePresentation(ev, bounds);
  88. }
  89.  
  90. //----------------------------------------------------------------------------------------
  91. void
  92. CDataContent::ExternalizeKind(Environment* ev,
  93.                             ODStorageUnit* storageUnit,
  94.                             FW_CKind* kind,
  95.                             FW_StorageKinds storageKind,
  96.                             FW_CPromise* promise,
  97.                             FW_CCloneInfo* cloneInfo)
  98. {
  99.     FW_UNUSED(ev);
  100.     FW_UNUSED(storageUnit);
  101.     FW_UNUSED(kind);
  102.     FW_UNUSED(storageKind);
  103.     FW_UNUSED(promise);
  104.     FW_UNUSED(cloneInfo);
  105. }
  106.  
  107. //----------------------------------------------------------------------------------------
  108. FW_Boolean 
  109. CDataContent::InternalizeKind(Environment* ev,
  110.                             ODStorageUnit* storageUnit, 
  111.                             FW_CKind* kind,
  112.                             FW_StorageKinds storageKind,
  113.                             FW_CCloneInfo* cloneInfo)
  114. {
  115.     FW_UNUSED(ev);
  116.     FW_UNUSED(storageUnit);
  117.     FW_UNUSED(kind);
  118.     FW_UNUSED(storageKind);
  119.     FW_UNUSED(cloneInfo);
  120.     return FALSE;
  121. }
  122.